#include "..\..\include\guiapppassword.h"

GUIAppPassword::GUIAppPassword(int id, float x, float y, float w, hgeFont *fnt, char* str ) : GUIAppEdit(id, x, y, w, fnt, str ) {
}

void GUIAppPassword::Render() {
	hge->Gfx_RenderLine(rect.x1, rect.y1, rect.x2, rect.y1, frameColor);
	hge->Gfx_RenderLine(rect.x2, rect.y1, rect.x2, rect.y2, frameColor);
	hge->Gfx_RenderLine(rect.x2, rect.y2, rect.x1, rect.y2, frameColor);
	hge->Gfx_RenderLine(rect.x1, rect.y2, rect.x1, rect.y1, frameColor);
	
	m_Font->SetColor(textColor);
	char tmpstr[1024];
	memset(tmpstr,'*',strlen(m_Text));
	tmpstr[strlen(m_Text)] = 0;
	m_Font->Render(rect.x1 + 2, rect.y1 + 2, HGETEXT_LEFT, tmpstr);
	
	if (m_Focus && m_Blink) {
		char tmp[1024]; 
		strncpy(tmp, tmpstr, m_Pos);
		tmp[m_Pos] = 0;
		
		float p = m_Font->GetStringWidth(tmp);
		hge->Gfx_RenderLine(rect.x1 + 2 + p, rect.y1 + 2, rect.x1 + 2 + p, rect.y2 - 2, 0xFFFFFFFF);
	}
}